package util.content;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/*接收字符串，打乱顺序后重新拿出*/

public class RandomContent {

	// 接收字符串的ArrayList
	List<String> contentList = new ArrayList<String>();

	// 接收字符串的方法
	public void contentAdd(String content) {

		contentList.add(content);
	}

	public void clear() {

		contentList.clear();
	}

	// 打乱顺序的方法后再输出的方法
	public String getWycContent() {
		String wycContent = "";
		int length = contentList.size();
		Random random = new Random();
		for (int i = 0; i < length; i++) {
			int r = random.nextInt(length - i);
			wycContent = wycContent + contentList.get(r);
			contentList.set(r, contentList.get(length - 1 - i));
		}
		return wycContent;
	}

}
